<template>
  <view v-if="!list || list.length <= 0">
    <default-space type="item" content="暂无内容"> </default-space>
  </view>
  <view class="dynamic-form__list" v-else>
    <navigator
      class="dynamic-form__list-item"
      v-for="form in list"
      :key="form.id"
      :url="`/pages-content/dynamicFormDemo/index?form_id=${form_id}&dataId=${form.dataId}`"
    >
      <view>
        <view class="dynamic-form__list-item-title">{{ form.title }}</view>
        <view class="dynamic-form__list-item-status">审核状态：{{ mapFormStatus(form.spflag) }}</view>
        <view class="dynamic-form__list-item-time">申请时间：{{ form.createTime }}</view>
      </view>
      <!-- <view>
          <view>评价</view>
          <view style="margin: 7px 0">
            <image style="width: 32rpx; height: 32rpx" />
          </view>
          <view>未评价</view>
        </view> -->
    </navigator>
  </view>
</template>

<script>
import { requestProtocol, domain } from '@/common/constant.js'
export default {
  props: {},
  data() {
    return {
      form_id: '',
      pageNumber: 1,
      list: [],
    }
  },
  computed: {
    open_id() {
      return uni.getStorageSync('USERINFO').openId || uni.getStorageSync('USERINFO').id
    },
  },
  onLoad(options) {
    const { form_id } = options
    this.form_id = form_id
    this.getFormApplyList()
  },
  mounted() {},
  watch: {},
  methods: {
    mapFormStatus(status) {
      return {
        2: '已办结',
        1: '处理中',
        0: '待审',
        '-2': '已退回',
      }[status]
    },
    async getFormApplyList() {
      let options = {
        open_id: this.open_id,
        pageNumber: this.pageNumber,
        formId: this.form_id,
      }
      const [error, { data }] = await uni.request({
        url: `${requestProtocol}${domain}/smallapp/formController/getHistoryList`,
        header: {
          'content-type': 'application/x-www-form-urlencoded',
        },
        data: options,
        method: 'POST',
      })
      if (error) {
        console.error(error)
        return
      }
      this.list = data.list
      console.log(data)
    },
  },
  components: {},
  onReachBottom() {
    console.log('到底了！')
  },
}
</script>

<style lang="scss">
.dynamic-form {
  &__list {
    min-height: 100vh;
    background-color: #fafafa;
    &-item {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      margin: 10px 10px 0 10px;
      & > view:first-child {
        padding: 15rpx;
        flex: 1;

        color: rgba(0, 0, 0, 0.25);
        font-size: 12px;
      }
      & > view:nth-child(2) {
        padding: 10rpx 0;
        font-size: 12px;
        text-align: center;
        width: 250rpx;
        height: auto;
        mask: radial-gradient(circle at 10rpx, transparent 7rpx, red 0) -10rpx / 110% 26rpx;
        background: #cccccc;
        color: #ffffff;
      }
    }
    &-item {
      background-color: #ffffff;
      &-title {
        font-size: 14px;
        color: #000000;
        margin-bottom: 21rpx;
      }
    }
  }
}
</style>
